package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicProGetItemDAO;
import com.cssy.yd.logic.entity.LogicProGetItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-12
 */
public class LogicProGetItemDAOImpl extends SqlMapClientDaoSupport implements LogicProGetItemDAO {

    /**
     * 插入数据
     * @param logicProGetItemDO
     * @return 插入数据的主键
     */
    public String insertLogicProGetItemDO(LogicProGetItemDO logicProGetItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicProGetItem.insert", logicProGetItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicProGetItemDO
     * @return 查出的记录数
     */
    public Integer countLogicProGetItemDOByExample(LogicProGetItemDO logicProGetItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProGetItem.countByDOExample", logicProGetItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicProGetItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicProGetItemDO(LogicProGetItemDO logicProGetItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicProGetItem.update", logicProGetItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicProGetItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicProGetItemDO> findListByExample(LogicProGetItemDO logicProGetItemDO) throws DataAccessException {
        List<LogicProGetItemDO> list = getSqlMapClientTemplate().queryForList("LogicProGetItem.findListByDO", logicProGetItemDO);
        return list;
    }

    /**
     * 根据主键获取logicProGetItemDO
     * @param id
     * @return logicProGetItemDO
     */
    public LogicProGetItemDO findLogicProGetItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicProGetItemDO logicProGetItemDO = (LogicProGetItemDO) getSqlMapClientTemplate().queryForObject("LogicProGetItem.findByPrimaryKey", id);
        return logicProGetItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicProGetItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProGetItem.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicProGetItemDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicProGetItemDO> list = getSqlMapClientTemplate().queryForList("LogicProGetItem_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProGetItem_ex.count", scs);
		return count;
	}

	@Override
	public Integer deleteLogicProGetItemPrimaryKey(String id)
			throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProGetItem_ex.deleteByProGetPrimaryKey", id);
        return rows;
	}

	@Override
	public Double sumQuantity(SearchConditions scs) throws DataAccessException {
		Double count = (Double) getSqlMapClientTemplate().queryForObject("LogicProGetItem_ex.sumquantity", scs);
		return count;
	}

}